Easy2Siksha.com
Sometimes, sorting the mess first helps us find what we’re really looking for — both in
numbers and in life!
So the next time someone hands you a jumbled list of numbers and asks for the ith smallest
or jth largest — smile, sort, and solve!
SECTION-C
5. (a) Define recursion. What are the conditions for implementing recursion?
(b) Write a recursive function to generate ith term of Fibonacci series.
Ans: (a). A Fresh Start: Grandma's Ladder
Imagine a little boy named Rohan who wanted to climb a ladder to reach a jar of cookies
placed on the top shelf. But the ladder was magical — it could only be climbed one step at a
time, and Rohan had to call himself again at each step to keep going higher.
Each time he placed his foot on a new step, he whispered, "Rohan, climb the next step," and
a new Rohan appeared to do just that. This continued until he reached the top. Once he got
the cookies, all the Rohans started disappearing one by one, climbing down as they had
come up. That’s recursion in action!
What is Recursion?
In programming, recursion is a process where a function calls itself to solve a smaller version
of the original problem. It continues to do this until it reaches a situation where it no longer
needs to call itself — this is known as the base condition.
So, just like Rohan climbed each step with the help of a new “version” of himself, in
recursion, the same function solves a part of the problem and calls itself again with a
smaller input — until the problem becomes small enough to solve directly.
Formal Definition:
Recursion is a programming technique in which a function calls itself directly or indirectly in
order to solve a problem by breaking it down into smaller sub-problems of the same type.
Real-life Analogy: Russian Dolls
Think of those famous Russian nesting dolls. You open the largest doll, and inside it, there’s
a slightly smaller one — and inside that, another, and so on — until you reach the smallest
one, which cannot be opened. That smallest doll is like the base condition in recursion, and